package com.shijie.log.comparator;

import org.springframework.util.ObjectUtils;

/**
 * 通用字段对比器工具类：集中管理基础对比逻辑
 */
public class FieldComparatorUtil {

    /**
     * 默认对比：null安全，全量匹配
     */
    public static final FieldComparator<Object> DEFAULT_COMPARATOR = ObjectUtils::nullSafeEquals;

    /**
     * 字符串对比：忽略大小写
     */
    public static final FieldComparator<String> STR_IGNORE_CASE_COMPARATOR = (oldVal, newVal) -> {
        if (ObjectUtils.nullSafeEquals(oldVal, newVal)) return true;
        return oldVal != null && oldVal.equalsIgnoreCase(newVal);
    };

}